/*----------------------------------------------------------------------------
Owner(s): Shane Whitfield
$Copyright: $
$Id: 

Purpose  : 
----------------------------------------------------------------------------*/

#pragma once

#include "singleton.h"
#include "nncommand.h"


/*--------------------------------------------------------------------------*/
// Class CWorld declaration.
class CTimeMgr : public TSingleton<CTimeMgr>, public CCommandTaker, public CSubsystem
{
	typedef CSubsystem super;
public:
			CTimeMgr();
			
			
	//CCommandTaker Overrides
	virtual const char*	GetName() const {
							return "time"; }
	virtual void		On_Command(const char* i_command, const char* i_parameters);
			
	void	Update(float dt);
	
	float	Dt() const {
					return m_dt; }
	float	T() const {
					return m_t; }
	float	SystemDt() const {
					return m_systemDt; }
	float	SystemT() const {
					return m_systemT; }
					
	void	Pause() {
				setState(EState_Paused); }
	void	Run() {
				setState(EState_Running); }
				
	bool	IsPaused() {
				return m_state == EState_Paused; }
	bool	IsRunning() {
				return m_state == EState_Running; }
	
private:

	enum EState
	{
		EState_Running,
		EState_Paused,
	};
	
	void setState(EState i_state);
	
	EState	m_state;
	float	m_dt;
	float	m_t;
	float	m_systemDt;
	float	m_systemT;
	bool	m_pausedForSystemMessage;
};
inline CTimeMgr& CTimeMgr_GetSingleton() { return CTimeMgr::GetSingleton(); }
#define g_timemgr (CTimeMgr_GetSingleton())

inline float T()
{
	return g_timemgr.T();
}

inline float Dt()
{
	return g_timemgr.Dt();
}

inline float SystemT()
{
	return g_timemgr.SystemT();
}

inline float SystemDt()
{
	return g_timemgr.SystemDt();
}


/*-----------------------------------EOF!-----------------------------------*/